var express = require('express');
var router = express.Router();
var data = require('../staticData')

router.post('/login',function(req,res,next){
  var username = req.body.username,password = req.body.password;
  if(!username || !password){
    return res.json({code:101,msg:'fail'});
  }

  var result = data.users.filter(o=>o.username==username && o.password===password);
  if(result.length==0){
    return res.json({code:102,msg:'用户名/密码不正确'});
  }else{
    return res.json({code:100,data:result[0]});
  }
});

router.post('/list',function(req,res,next){
  return res.json({code:100,data:data.list});
});


module.exports = router;
